package com.ruoyi.project.mahjong.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mahjong.domain.TRecord;
import com.ruoyi.project.mahjong.service.ITRecordService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 整体流水Controller
 * 
 * @author ruoyi
 * @date 2023-10-07
 */
@RestController
@RequestMapping("/mahjong/record")
public class TRecordController extends BaseController
{
    @Autowired
    private ITRecordService tRecordService;

    /**
     * 查询整体流水列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(TRecord tRecord)
    {
        startPage();
        List<TRecord> list = tRecordService.selectTRecordList(tRecord);
        return getDataTable(list);
    }

    /**
     * 导出整体流水列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:record:export')")
    @Log(title = "整体流水", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TRecord tRecord)
    {
        List<TRecord> list = tRecordService.selectTRecordList(tRecord);
        ExcelUtil<TRecord> util = new ExcelUtil<TRecord>(TRecord.class);
        return util.exportExcel(list, "record");
    }

    /**
     * 获取整体流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('mahjong:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tRecordService.selectTRecordById(id));
    }

    /**
     * 新增整体流水
     */
    @PreAuthorize("@ss.hasPermi('mahjong:record:add')")
    @Log(title = "整体流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TRecord tRecord)
    {
        return toAjax(tRecordService.insertTRecord(tRecord));
    }

    /**
     * 修改整体流水
     */
    @PreAuthorize("@ss.hasPermi('mahjong:record:edit')")
    @Log(title = "整体流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TRecord tRecord)
    {
        return toAjax(tRecordService.updateTRecord(tRecord));
    }

    /**
     * 删除整体流水
     */
    @PreAuthorize("@ss.hasPermi('mahjong:record:remove')")
    @Log(title = "整体流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tRecordService.deleteTRecordByIds(ids));
    }
}
